/** @author Chris Howson & Steven Horsman */
class SolverData
{
	//If set to true then cell could contain that number
	/**Array of boolean values*/
	private Boolean[] cells;
	/**Number of true fields in cells array*/
	private int poss;
	
	/**Constructor*/
	public SolverData() {
		cells = new Boolean[9];
		poss = 9;
	}
	
	/**Constructor*/
	public SolverData(SolverData bob) {
		
		cells = new Boolean[9];
		for(int i = 0; i < 9; i++)
		{
			if(bob.cells[i])
			{
				this.cells[i] = true;
			}
			else
			{
				this.cells[i] = false;
			}
		}
		poss = bob.poss;
	}
	
	/**Sets all the values in the cells array to true*/
	public void setalltrue()
	{
		for(int i = 0; i < 9; i++)
		{
			this.cells[i] = true;
		}
		
	}
	
	/**Returns the position in cells of the delayed true value*/
	public int getOnePoss(int delay)
	{
		for(int i = 0; i < 9; i++)
		{
			if(this.cells[i])
			{
				//System.out.println("delay:" + delay + "leads to " + (i+1));
				delay--;
				//System.out.println("delay:" + delay + "leads to " + (i+1));
				if(delay == 0) { return i+1; }
			}
		}
		System.err.println("can't find next true, poss = " + poss);
		System.exit(-1);
		return -1;
	}
	
	/**Sets cells[number] in the cells array to true*/
	public void setfalse(int number)
	{
		if (this.cells[number])
		{
			this.cells[number] = false;
			this.poss = this.poss - 1;
		}
	}
	
	/**Sets all the values in the cells array to true*/
	public void setallfalse()
	{
		for(int i = 0 ; i < 9; i++)
		{
			this.cells[i] = false;
		}
		this.poss = 0;
	}
	
	/**Returns the Poss field*/
	public int getPoss()
	{
		return poss;
	}
	
	/**Prints out each of the booleans stored in cells*/
	public String print()
	{
		String p  = "{"+cells[0] + ","+cells[1] + ","+cells[2] + ","+cells[3] + ","+cells[4] + ","+cells[5] + ","+cells[6] + ","+cells[7] + ","+cells[8] + "}";
		return p;
	}
	
	/**Returns the boolean stored in cells[cellno]*/
	public Boolean getCell(int cellno)
	{
		return this.cells[cellno];
	}
}